import React, { Component } from 'react'
import Style from './index.scss'

export default class Coupon extends Component {
	constructor(props) {
		 super(props);

		 this.state = {}
	}

	clickCoupon(data) {
		/*if(!this.props.Selected){
			//选中*/
			if(this.props.onClick){
				this.props.onClick(data); //传递给父组件
			}
	/*	}else{
			//不选
			if(this.props.onClick){
				this.props.onClick(-1); //传递给父组件
			}
		}*/
	}

	render() {
		const couponSelected = this.props.Selected ? " " + Style.couponSelected : ""; //选中的样式
		return (
			<div className={Style.flex + " " + Style.coupon + couponSelected} onClick={(amount) => this.clickCoupon(this.props)}>
				<div className={Style.couponAmount}><span>{this.props.couponAmount}</span><span>元</span></div>
				<div className={Style.flex1 + " " + Style.text}>
					<div className={Style.title}>{this.props.couponTitle}</div>
					<div className={Style.des}>有效期至 {this.props.invalidDate.split(' ')[0]}</div>
				</div>
			</div>
		)
	}
}

Coupon.defaultProps = {
}